﻿using AiShou.BLL;
using AiShou.IBLL;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace AiShou.WebSite
{
    
    /// <summary>
    /// DiscussListHandler 的摘要说明 评论列表处理程序
    /// </summary>
    public class DiscussListHandler : IHttpHandler
    {
        /// <summary>
        /// 处理请求
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {

            // 取值
             var videoId=context.Request.QueryString["id"];
             var pageNumber = Convert.ToInt32(context.Request.QueryString["pageNumber"]);
             var pageSize = Convert.ToInt32(context.Request.QueryString["pageSize"]);
            // 读取列表
            IDiscussManager manager = new DiscussManager();
            var list=  manager.QueryDiscusses(videoId, pageNumber, pageSize);
            //返回结果
            var json=JsonConvert.SerializeObject(list, new UnixDateTimeConverter());
            context.Response.ContentType = "application/json";
            context.Response.Write(json);
            context.Response.End();
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}